﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Microsoft.MediaCenter.UI;
using System.Windows.Forms;

namespace Playkanaler
{
    // 
    //

    public class fileXhelp : ModelItem
    {
        string file = "";
        public string File
        {
            get { return file; }
            set
            {
                file = value;
                FirePropertyChanged("File");
            }

        }
        string folder = "";
        public string Folder
        {
            get { return folder; }
            set
            {
                folder = value;
                FirePropertyChanged("Folder");
            }

        }
        public ArrayListDataSet GetDrives()
        {
            ArrayListDataSet al = new ArrayListDataSet();
            foreach (DriveInfo dri in DriveInfo.GetDrives())
            {
                if (dri.DriveType == DriveType.Fixed || dri.DriveType == DriveType.Network)
                {
                    al.Add(dri.RootDirectory);
                }

            }



            return al;
        }
        void addpath(object obj)
        {

        }
        public fileXhelp()
        {
            Blocks.Add(GetDrives());
            ArrayListDataSet al = new ArrayListDataSet();
            DirectoryInfo diii = new DirectoryInfo("c:\\");

        }
        public void msg()
        {
            string s = "";
            foreach (DirectoryInfo dii in blocks)
            {
                s += dii.Name + "\n";
            }
            MessageBox.Show(s);
        }

        public void AddBlock(DirectoryInfo di, int index)
        {
            for (int i = index + 1; i < blocks.Count; i++)
            {
                Blocks.RemoveAt(i);
            }
            Blocks.Insert(index + 1, di);


        }

        string path = "";
        public string Path
        {
            get { return path; }
            set
            {
                path = value;
            }
        }
        DirectoryInfo di;
        public DirectoryInfo DirInfo
        {
            get { return new DirectoryInfo(path); }
        }
        ArrayListDataSet blocks = new ArrayListDataSet();
        public ArrayListDataSet Blocks
        {
            get { return blocks; }
            set
            {
                blocks = value;
                FirePropertyChanged("Blocks");
            }
        }

        public ArrayListDataSet GetAll(DirectoryInfo dii)
        {


            ArrayListDataSet list = new ArrayListDataSet();
            try
            {
                foreach (DirectoryInfo di in dii.GetDirectories())
                {

                    list.Add(di);
                }



                foreach (FileInfo di in dii.GetFiles())
                {
                    list.Add(di);
                }
            }
            catch (Exception)
            {

            }

            return list;


        }


        public ArrayListDataSet All
        {
            get
            {
                ArrayListDataSet list = new ArrayListDataSet();

                foreach (DirectoryInfo di in DirInfo.GetDirectories())
                {

                    list.Add(di);
                }

                foreach (FileInfo di in DirInfo.GetFiles())
                {
                    list.Add(di);
                }

                return list;

            }
        }
    }
}
